package edu.sju.ssm;

import java.util.List;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import edu.sju.ssm.config.DataAccessConfig;
import edu.sju.ssm.config.ServiceConfig;
import edu.sju.ssm.entity.Publisher;
import edu.sju.ssm.service.PublisherService;

public class TransactionTest {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DataAccessConfig.class, ServiceConfig.class);
		
		PublisherService publisherService = ctx.getBean(PublisherService.class);
		
		int count = publisherService.getPublisherCount();
		
		System.out.println("出版社数量：" + count);
		
		Publisher p = new Publisher("新华出版社", 1950, "不需要介绍的出版社");
		publisherService.addNewPublisher(p);
		
		System.out.printf("出版社数量：%d%n", publisherService.getPublisherCount());
		
		List<Publisher> publishers = publisherService.getAllPublishers();
		
		for (Publisher publisher : publishers) {
			System.out.println(publisher);
		}

	}

}
